package com.miukoo.aikao.core.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
　* 在线编程代码
　* @Author miukoo<miukoo@126.com>
　* @Date 2020/11/29 7:12
　* @Version 1.0
  */
@NoArgsConstructor
@AllArgsConstructor
@Getter
public enum CodingType implements Serializable {


    /**
     * 通用错误，接口参数不全
     */
    JAVA(0,"text/x-java"),
    SQL(1,"text/sql"),
    HTML(2,"text/html");

    public int code;
    public String type;


    /**
     * 查找默认类型
     * @param code
     * @return
     */
    public static CodingType getType(Short code) {
        if(code!=null) {
            for (CodingType e : CodingType.values()) {
                if (e.getCode() == code.intValue()) {
                    return e;
                }
            }
        }
        return JAVA;
    }
}
